/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'regional';
  @endpointMap = {
    ap-northeast-1 = 'linkvisual.aliyuncs.com',
    ap-northeast-2-pop = 'linkvisual.aliyuncs.com',
    ap-south-1 = 'linkvisual.aliyuncs.com',
    ap-southeast-1 = 'linkvisual.aliyuncs.com',
    ap-southeast-2 = 'linkvisual.aliyuncs.com',
    ap-southeast-3 = 'linkvisual.aliyuncs.com',
    ap-southeast-5 = 'linkvisual.aliyuncs.com',
    cn-beijing = 'linkvisual.aliyuncs.com',
    cn-beijing-finance-1 = 'linkvisual.aliyuncs.com',
    cn-beijing-finance-pop = 'linkvisual.aliyuncs.com',
    cn-beijing-gov-1 = 'linkvisual.aliyuncs.com',
    cn-beijing-nu16-b01 = 'linkvisual.aliyuncs.com',
    cn-chengdu = 'linkvisual.aliyuncs.com',
    cn-edge-1 = 'linkvisual.aliyuncs.com',
    cn-fujian = 'linkvisual.aliyuncs.com',
    cn-haidian-cm12-c01 = 'linkvisual.aliyuncs.com',
    cn-hangzhou-bj-b01 = 'linkvisual.aliyuncs.com',
    cn-hangzhou-finance = 'linkvisual.aliyuncs.com',
    cn-hangzhou-internal-prod-1 = 'linkvisual.aliyuncs.com',
    cn-hangzhou-internal-test-1 = 'linkvisual.aliyuncs.com',
    cn-hangzhou-internal-test-2 = 'linkvisual.aliyuncs.com',
    cn-hangzhou-internal-test-3 = 'linkvisual.aliyuncs.com',
    cn-hangzhou-test-306 = 'linkvisual.aliyuncs.com',
    cn-hongkong = 'linkvisual.aliyuncs.com',
    cn-hongkong-finance-pop = 'linkvisual.aliyuncs.com',
    cn-huhehaote = 'linkvisual.aliyuncs.com',
    cn-north-2-gov-1 = 'linkvisual.aliyuncs.com',
    cn-qingdao = 'linkvisual.aliyuncs.com',
    cn-qingdao-nebula = 'linkvisual.aliyuncs.com',
    cn-shanghai-et15-b01 = 'linkvisual.aliyuncs.com',
    cn-shanghai-et2-b01 = 'linkvisual.aliyuncs.com',
    cn-shanghai-finance-1 = 'linkvisual.aliyuncs.com',
    cn-shanghai-inner = 'linkvisual.aliyuncs.com',
    cn-shanghai-internal-test-1 = 'linkvisual.aliyuncs.com',
    cn-shenzhen = 'linkvisual.aliyuncs.com',
    cn-shenzhen-finance-1 = 'linkvisual.aliyuncs.com',
    cn-shenzhen-inner = 'linkvisual.aliyuncs.com',
    cn-shenzhen-st4-d01 = 'linkvisual.aliyuncs.com',
    cn-shenzhen-su18-b01 = 'linkvisual.aliyuncs.com',
    cn-wuhan = 'linkvisual.aliyuncs.com',
    cn-yushanfang = 'linkvisual.aliyuncs.com',
    cn-zhangbei-na61-b01 = 'linkvisual.aliyuncs.com',
    cn-zhangjiakou = 'linkvisual.aliyuncs.com',
    cn-zhangjiakou-na62-a01 = 'linkvisual.aliyuncs.com',
    cn-zhengzhou-nebula-1 = 'linkvisual.aliyuncs.com',
    eu-central-1 = 'linkvisual.aliyuncs.com',
    eu-west-1 = 'linkvisual.aliyuncs.com',
    eu-west-1-oxs = 'linkvisual.aliyuncs.com',
    me-east-1 = 'linkvisual.aliyuncs.com',
    rus-west-1-pop = 'linkvisual.aliyuncs.com',
    us-east-1 = 'linkvisual.aliyuncs.com',
    us-west-1 = 'linkvisual.aliyuncs.com',
  };

  checkConfig(config);
  @endpoint = getEndpoint('linkvisual', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model BatchBindDeviceRequest {
  deviceList?: [ 
    {
      deviceName?: string(name='DeviceName'),
      iotId?: string(name='IotId'),
      productKey?: string(name='ProductKey'),
    }
  ](name='DeviceList'),
  identityId?: string(name='IdentityId'),
  openId?: string(name='OpenId'),
  openIdAppKey?: string(name='OpenIdAppKey'),
}

model BatchBindDeviceResponseBody = {
  code?: string(name='Code'),
  data?: {
    bindDeviceList?: [ 
      {
        bindResultCode?: int32(name='BindResultCode'),
        bindResultMessage?: string(name='BindResultMessage'),
        deviceName?: string(name='DeviceName'),
        iotId?: string(name='IotId'),
        productKey?: string(name='ProductKey'),
      }
    ](name='BindDeviceList'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model BatchBindDeviceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: BatchBindDeviceResponseBody(name='body'),
}

async function batchBindDeviceWithOptions(request: BatchBindDeviceRequest, runtime: Util.RuntimeOptions): BatchBindDeviceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.deviceList)) {
    query['DeviceList'] = request.deviceList;
  }
  if (!Util.isUnset(request.identityId)) {
    query['IdentityId'] = request.identityId;
  }
  if (!Util.isUnset(request.openId)) {
    query['OpenId'] = request.openId;
  }
  if (!Util.isUnset(request.openIdAppKey)) {
    query['OpenIdAppKey'] = request.openIdAppKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'BatchBindDevice',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function batchBindDevice(request: BatchBindDeviceRequest): BatchBindDeviceResponse {
  var runtime = new Util.RuntimeOptions{};
  return batchBindDeviceWithOptions(request, runtime);
}

model BindStorageOrderRequest {
  deviceName?: string(name='DeviceName'),
  enableDefaultPlan?: boolean(name='EnableDefaultPlan'),
  eventRecordDuration?: int32(name='EventRecordDuration'),
  eventRecordProlong?: boolean(name='EventRecordProlong'),
  iotId?: string(name='IotId'),
  maxRecordFileDuration?: int32(name='MaxRecordFileDuration'),
  orderId?: string(name='OrderId'),
  preRecordDuration?: int32(name='PreRecordDuration'),
  productKey?: string(name='ProductKey'),
  userId?: string(name='UserId'),
  userName?: string(name='UserName'),
}

model BindStorageOrderResponseBody = {
  code?: string(name='Code'),
  data?: {
    commodityCode?: string(name='CommodityCode'),
    copies?: int32(name='Copies'),
    endTime?: string(name='EndTime'),
    endTimeUTC?: string(name='EndTimeUTC'),
    identityId?: string(name='IdentityId'),
    iotId?: string(name='IotId'),
    orderId?: string(name='OrderId'),
    orderType?: int32(name='OrderType'),
    outOrderNo?: string(name='OutOrderNo'),
    paymentStatus?: int32(name='PaymentStatus'),
    preConsume?: int32(name='PreConsume'),
    price?: string(name='Price'),
    recordType?: int32(name='RecordType'),
    specification?: string(name='Specification'),
    startTime?: string(name='StartTime'),
    startTimeUTC?: string(name='StartTimeUTC'),
    status?: int32(name='Status'),
    userId?: string(name='UserId'),
    userName?: string(name='UserName'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model BindStorageOrderResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: BindStorageOrderResponseBody(name='body'),
}

async function bindStorageOrderWithOptions(request: BindStorageOrderRequest, runtime: Util.RuntimeOptions): BindStorageOrderResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.deviceName)) {
    query['DeviceName'] = request.deviceName;
  }
  if (!Util.isUnset(request.enableDefaultPlan)) {
    query['EnableDefaultPlan'] = request.enableDefaultPlan;
  }
  if (!Util.isUnset(request.eventRecordDuration)) {
    query['EventRecordDuration'] = request.eventRecordDuration;
  }
  if (!Util.isUnset(request.eventRecordProlong)) {
    query['EventRecordProlong'] = request.eventRecordProlong;
  }
  if (!Util.isUnset(request.iotId)) {
    query['IotId'] = request.iotId;
  }
  if (!Util.isUnset(request.maxRecordFileDuration)) {
    query['MaxRecordFileDuration'] = request.maxRecordFileDuration;
  }
  if (!Util.isUnset(request.orderId)) {
    query['OrderId'] = request.orderId;
  }
  if (!Util.isUnset(request.preRecordDuration)) {
    query['PreRecordDuration'] = request.preRecordDuration;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  if (!Util.isUnset(request.userId)) {
    query['UserId'] = request.userId;
  }
  if (!Util.isUnset(request.userName)) {
    query['UserName'] = request.userName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'BindStorageOrder',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function bindStorageOrder(request: BindStorageOrderRequest): BindStorageOrderResponse {
  var runtime = new Util.RuntimeOptions{};
  return bindStorageOrderWithOptions(request, runtime);
}

model CheckFreeStorageValidRequest {
  deviceName?: string(name='DeviceName'),
  iotId?: string(name='IotId'),
  productKey?: string(name='ProductKey'),
}

model CheckFreeStorageValidResponseBody = {
  code?: string(name='Code'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model CheckFreeStorageValidResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CheckFreeStorageValidResponseBody(name='body'),
}

async function checkFreeStorageValidWithOptions(request: CheckFreeStorageValidRequest, runtime: Util.RuntimeOptions): CheckFreeStorageValidResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.deviceName)) {
    query['DeviceName'] = request.deviceName;
  }
  if (!Util.isUnset(request.iotId)) {
    query['IotId'] = request.iotId;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CheckFreeStorageValid',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function checkFreeStorageValid(request: CheckFreeStorageValidRequest): CheckFreeStorageValidResponse {
  var runtime = new Util.RuntimeOptions{};
  return checkFreeStorageValidWithOptions(request, runtime);
}

model ConsumeFreeStorageRequest {
  deviceName?: string(name='DeviceName'),
  enableDefaultPlan?: boolean(name='EnableDefaultPlan'),
  eventRecordDuration?: int32(name='EventRecordDuration'),
  eventRecordProlong?: boolean(name='EventRecordProlong'),
  immediateUse?: boolean(name='ImmediateUse'),
  iotId?: string(name='IotId'),
  preRecordDuration?: int32(name='PreRecordDuration'),
  productKey?: string(name='ProductKey'),
  quota?: int32(name='Quota'),
}

model ConsumeFreeStorageResponseBody = {
  code?: string(name='Code'),
  data?: {
    consumed?: int32(name='Consumed'),
    endTime?: string(name='EndTime'),
    endTimeUTC?: string(name='EndTimeUTC'),
    expired?: int32(name='Expired'),
    lifecycle?: int32(name='Lifecycle'),
    months?: int32(name='Months'),
    remainQuota?: int32(name='RemainQuota'),
    startTime?: string(name='StartTime'),
    startTimeUTC?: string(name='StartTimeUTC'),
    type?: int32(name='Type'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model ConsumeFreeStorageResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ConsumeFreeStorageResponseBody(name='body'),
}

async function consumeFreeStorageWithOptions(request: ConsumeFreeStorageRequest, runtime: Util.RuntimeOptions): ConsumeFreeStorageResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.deviceName)) {
    query['DeviceName'] = request.deviceName;
  }
  if (!Util.isUnset(request.enableDefaultPlan)) {
    query['EnableDefaultPlan'] = request.enableDefaultPlan;
  }
  if (!Util.isUnset(request.eventRecordDuration)) {
    query['EventRecordDuration'] = request.eventRecordDuration;
  }
  if (!Util.isUnset(request.eventRecordProlong)) {
    query['EventRecordProlong'] = request.eventRecordProlong;
  }
  if (!Util.isUnset(request.immediateUse)) {
    query['ImmediateUse'] = request.immediateUse;
  }
  if (!Util.isUnset(request.iotId)) {
    query['IotId'] = request.iotId;
  }
  if (!Util.isUnset(request.preRecordDuration)) {
    query['PreRecordDuration'] = request.preRecordDuration;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  if (!Util.isUnset(request.quota)) {
    query['Quota'] = request.quota;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ConsumeFreeStorage',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function consumeFreeStorage(request: ConsumeFreeStorageRequest): ConsumeFreeStorageResponse {
  var runtime = new Util.RuntimeOptions{};
  return consumeFreeStorageWithOptions(request, runtime);
}

model CreateAndPayStorageOrderRequest {
  commodityCode?: string(name='CommodityCode'),
  copies?: int32(name='Copies'),
  deviceName?: string(name='DeviceName'),
  deviceNoOwner?: boolean(name='DeviceNoOwner'),
  enableDefaultPlan?: boolean(name='EnableDefaultPlan'),
  eventRecordDuration?: int32(name='EventRecordDuration'),
  eventRecordProlong?: boolean(name='EventRecordProlong'),
  immediateUse?: boolean(name='ImmediateUse'),
  iotId?: string(name='IotId'),
  maxRecordFileDuration?: int32(name='MaxRecordFileDuration'),
  preRecordDuration?: int32(name='PreRecordDuration'),
  productKey?: string(name='ProductKey'),
  specification?: string(name='Specification'),
  userId?: string(name='UserId'),
  userName?: string(name='UserName'),
}

model CreateAndPayStorageOrderResponseBody = {
  code?: string(name='Code'),
  data?: {
    commodityCode?: string(name='CommodityCode'),
    copies?: int32(name='Copies'),
    endTime?: string(name='EndTime'),
    endTimeUTC?: string(name='EndTimeUTC'),
    identityId?: string(name='IdentityId'),
    iotId?: string(name='IotId'),
    orderId?: string(name='OrderId'),
    orderType?: int32(name='OrderType'),
    outOrderNo?: string(name='OutOrderNo'),
    paymentStatus?: int32(name='PaymentStatus'),
    preConsume?: int32(name='PreConsume'),
    price?: string(name='Price'),
    recordType?: int32(name='RecordType'),
    specification?: string(name='Specification'),
    startTime?: string(name='StartTime'),
    startTimeUTC?: string(name='StartTimeUTC'),
    status?: int32(name='Status'),
    userId?: string(name='UserId'),
    userName?: string(name='UserName'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model CreateAndPayStorageOrderResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateAndPayStorageOrderResponseBody(name='body'),
}

async function createAndPayStorageOrderWithOptions(request: CreateAndPayStorageOrderRequest, runtime: Util.RuntimeOptions): CreateAndPayStorageOrderResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.commodityCode)) {
    query['CommodityCode'] = request.commodityCode;
  }
  if (!Util.isUnset(request.copies)) {
    query['Copies'] = request.copies;
  }
  if (!Util.isUnset(request.deviceName)) {
    query['DeviceName'] = request.deviceName;
  }
  if (!Util.isUnset(request.deviceNoOwner)) {
    query['DeviceNoOwner'] = request.deviceNoOwner;
  }
  if (!Util.isUnset(request.enableDefaultPlan)) {
    query['EnableDefaultPlan'] = request.enableDefaultPlan;
  }
  if (!Util.isUnset(request.eventRecordDuration)) {
    query['EventRecordDuration'] = request.eventRecordDuration;
  }
  if (!Util.isUnset(request.eventRecordProlong)) {
    query['EventRecordProlong'] = request.eventRecordProlong;
  }
  if (!Util.isUnset(request.immediateUse)) {
    query['ImmediateUse'] = request.immediateUse;
  }
  if (!Util.isUnset(request.iotId)) {
    query['IotId'] = request.iotId;
  }
  if (!Util.isUnset(request.maxRecordFileDuration)) {
    query['MaxRecordFileDuration'] = request.maxRecordFileDuration;
  }
  if (!Util.isUnset(request.preRecordDuration)) {
    query['PreRecordDuration'] = request.preRecordDuration;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  if (!Util.isUnset(request.specification)) {
    query['Specification'] = request.specification;
  }
  if (!Util.isUnset(request.userId)) {
    query['UserId'] = request.userId;
  }
  if (!Util.isUnset(request.userName)) {
    query['UserName'] = request.userName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateAndPayStorageOrder',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createAndPayStorageOrder(request: CreateAndPayStorageOrderRequest): CreateAndPayStorageOrderResponse {
  var runtime = new Util.RuntimeOptions{};
  return createAndPayStorageOrderWithOptions(request, runtime);
}

model EnableFreeStorageRequest {
  deviceName?: string(name='DeviceName'),
  iotId?: string(name='IotId'),
  productKey?: string(name='ProductKey'),
}

model EnableFreeStorageResponseBody = {
  code?: string(name='Code'),
  data?: {
    consumed?: int32(name='Consumed'),
    endTime?: string(name='EndTime'),
    endTimeUTC?: string(name='EndTimeUTC'),
    expired?: int32(name='Expired'),
    lifecycle?: int32(name='Lifecycle'),
    months?: int32(name='Months'),
    remainQuota?: int32(name='RemainQuota'),
    startTime?: string(name='StartTime'),
    startTimeUTC?: string(name='StartTimeUTC'),
    type?: int32(name='Type'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model EnableFreeStorageResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: EnableFreeStorageResponseBody(name='body'),
}

async function enableFreeStorageWithOptions(request: EnableFreeStorageRequest, runtime: Util.RuntimeOptions): EnableFreeStorageResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.deviceName)) {
    query['DeviceName'] = request.deviceName;
  }
  if (!Util.isUnset(request.iotId)) {
    query['IotId'] = request.iotId;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'EnableFreeStorage',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function enableFreeStorage(request: EnableFreeStorageRequest): EnableFreeStorageResponse {
  var runtime = new Util.RuntimeOptions{};
  return enableFreeStorageWithOptions(request, runtime);
}

model EnableStorageOrderRequest {
  deviceName?: string(name='DeviceName'),
  iotId?: string(name='IotId'),
  orderId?: string(name='OrderId'),
  productKey?: string(name='ProductKey'),
}

model EnableStorageOrderResponseBody = {
  code?: string(name='Code'),
  data?: {
    commodityCode?: string(name='CommodityCode'),
    copies?: int32(name='Copies'),
    endTime?: string(name='EndTime'),
    endTimeUTC?: string(name='EndTimeUTC'),
    identityId?: string(name='IdentityId'),
    iotId?: string(name='IotId'),
    orderId?: string(name='OrderId'),
    orderType?: int32(name='OrderType'),
    outOrderNo?: string(name='OutOrderNo'),
    paymentStatus?: int32(name='PaymentStatus'),
    preConsume?: int32(name='PreConsume'),
    price?: string(name='Price'),
    recordType?: int32(name='RecordType'),
    specification?: string(name='Specification'),
    startTime?: string(name='StartTime'),
    startTimeUTC?: string(name='StartTimeUTC'),
    status?: int32(name='Status'),
    userId?: string(name='UserId'),
    userName?: string(name='UserName'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model EnableStorageOrderResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: EnableStorageOrderResponseBody(name='body'),
}

async function enableStorageOrderWithOptions(request: EnableStorageOrderRequest, runtime: Util.RuntimeOptions): EnableStorageOrderResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.deviceName)) {
    query['DeviceName'] = request.deviceName;
  }
  if (!Util.isUnset(request.iotId)) {
    query['IotId'] = request.iotId;
  }
  if (!Util.isUnset(request.orderId)) {
    query['OrderId'] = request.orderId;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'EnableStorageOrder',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function enableStorageOrder(request: EnableStorageOrderRequest): EnableStorageOrderResponse {
  var runtime = new Util.RuntimeOptions{};
  return enableStorageOrderWithOptions(request, runtime);
}

model FreezeFreeStorageRequest {
  deviceName?: string(name='DeviceName'),
  iotId?: string(name='IotId'),
  productKey?: string(name='ProductKey'),
}

model FreezeFreeStorageResponseBody = {
  code?: string(name='Code'),
  data?: {
    consumed?: int32(name='Consumed'),
    endTime?: string(name='EndTime'),
    endTimeUTC?: string(name='EndTimeUTC'),
    expired?: int32(name='Expired'),
    lifecycle?: int32(name='Lifecycle'),
    months?: int32(name='Months'),
    remainQuota?: int32(name='RemainQuota'),
    startTime?: string(name='StartTime'),
    startTimeUTC?: string(name='StartTimeUTC'),
    type?: int32(name='Type'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model FreezeFreeStorageResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: FreezeFreeStorageResponseBody(name='body'),
}

async function freezeFreeStorageWithOptions(request: FreezeFreeStorageRequest, runtime: Util.RuntimeOptions): FreezeFreeStorageResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.deviceName)) {
    query['DeviceName'] = request.deviceName;
  }
  if (!Util.isUnset(request.iotId)) {
    query['IotId'] = request.iotId;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'FreezeFreeStorage',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function freezeFreeStorage(request: FreezeFreeStorageRequest): FreezeFreeStorageResponse {
  var runtime = new Util.RuntimeOptions{};
  return freezeFreeStorageWithOptions(request, runtime);
}

model FreezeStorageOrderRequest {
  deviceName?: string(name='DeviceName'),
  deviceNoOwner?: boolean(name='DeviceNoOwner'),
  iotId?: string(name='IotId'),
  orderId?: string(name='OrderId'),
  productKey?: string(name='ProductKey'),
}

model FreezeStorageOrderResponseBody = {
  code?: string(name='Code'),
  data?: {
    commodityCode?: string(name='CommodityCode'),
    copies?: int32(name='Copies'),
    endTime?: string(name='EndTime'),
    endTimeUTC?: string(name='EndTimeUTC'),
    identityId?: string(name='IdentityId'),
    iotId?: string(name='IotId'),
    orderId?: string(name='OrderId'),
    orderType?: int32(name='OrderType'),
    outOrderNo?: string(name='OutOrderNo'),
    paymentStatus?: int32(name='PaymentStatus'),
    preConsume?: int32(name='PreConsume'),
    price?: string(name='Price'),
    recordType?: int32(name='RecordType'),
    specification?: string(name='Specification'),
    startTime?: string(name='StartTime'),
    startTimeUTC?: string(name='StartTimeUTC'),
    status?: int32(name='Status'),
    userId?: string(name='UserId'),
    userName?: string(name='UserName'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model FreezeStorageOrderResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: FreezeStorageOrderResponseBody(name='body'),
}

async function freezeStorageOrderWithOptions(request: FreezeStorageOrderRequest, runtime: Util.RuntimeOptions): FreezeStorageOrderResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.deviceName)) {
    query['DeviceName'] = request.deviceName;
  }
  if (!Util.isUnset(request.deviceNoOwner)) {
    query['DeviceNoOwner'] = request.deviceNoOwner;
  }
  if (!Util.isUnset(request.iotId)) {
    query['IotId'] = request.iotId;
  }
  if (!Util.isUnset(request.orderId)) {
    query['OrderId'] = request.orderId;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'FreezeStorageOrder',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function freezeStorageOrder(request: FreezeStorageOrderRequest): FreezeStorageOrderResponse {
  var runtime = new Util.RuntimeOptions{};
  return freezeStorageOrderWithOptions(request, runtime);
}

model GenerateDeviceRequest {
  amount?: long(name='Amount'),
  productKey?: string(name='ProductKey'),
  projectId?: string(name='ProjectId'),
}

model GenerateDeviceResponseBody = {
  code?: string(name='Code'),
  data?: {
    batchId?: string(name='BatchId'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model GenerateDeviceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GenerateDeviceResponseBody(name='body'),
}

async function generateDeviceWithOptions(request: GenerateDeviceRequest, runtime: Util.RuntimeOptions): GenerateDeviceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.amount)) {
    query['Amount'] = request.amount;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  if (!Util.isUnset(request.projectId)) {
    query['ProjectId'] = request.projectId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GenerateDevice',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function generateDevice(request: GenerateDeviceRequest): GenerateDeviceResponse {
  var runtime = new Util.RuntimeOptions{};
  return generateDeviceWithOptions(request, runtime);
}

model GenerateDeviceByBatchIdRequest {
  batchId?: string(name='BatchId'),
  productKey?: string(name='ProductKey'),
  projectId?: string(name='ProjectId'),
}

model GenerateDeviceByBatchIdResponseBody = {
  code?: string(name='Code'),
  data?: {
    batchId?: string(name='BatchId'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model GenerateDeviceByBatchIdResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GenerateDeviceByBatchIdResponseBody(name='body'),
}

async function generateDeviceByBatchIdWithOptions(request: GenerateDeviceByBatchIdRequest, runtime: Util.RuntimeOptions): GenerateDeviceByBatchIdResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.batchId)) {
    query['BatchId'] = request.batchId;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  if (!Util.isUnset(request.projectId)) {
    query['ProjectId'] = request.projectId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GenerateDeviceByBatchId',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function generateDeviceByBatchId(request: GenerateDeviceByBatchIdRequest): GenerateDeviceByBatchIdResponse {
  var runtime = new Util.RuntimeOptions{};
  return generateDeviceByBatchIdWithOptions(request, runtime);
}

model GetAccountByIdRequest {
  identityId?: string(name='IdentityId', example='5035op97******************a63994'),
  openId?: string(name='OpenId', example='60yqjd1**************************561da00851'),
  openIdAppKey?: string(name='OpenIdAppKey', example='76****57'),
}

model GetAccountByIdResponseBody = {
  code?: string(name='Code', example='400'),
  data?: {
    email?: string(name='Email', example='******'),
    gmtCreate?: long(name='GmtCreate', example='1700189358000'),
    gmtModified?: long(name='GmtModified', example='1700209499000'),
    identityId?: string(name='IdentityId', example='5035op97******************a63994'),
    lastLoginTime?: long(name='LastLoginTime', example='1700209499000'),
    loginName?: string(name='LoginName', example='18*******20'),
    nickName?: string(name='NickName', example='18*******20'),
    phone?: string(name='Phone', example='18*******20'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage', example='Unexpected internal error.'),
  requestId?: string(name='RequestId', example='E55***B7-4***-4***-8***-D3******F565'),
  success?: boolean(name='Success', example='true'),
}

model GetAccountByIdResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetAccountByIdResponseBody(name='body'),
}

async function getAccountByIdWithOptions(request: GetAccountByIdRequest, runtime: Util.RuntimeOptions): GetAccountByIdResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.identityId)) {
    query['IdentityId'] = request.identityId;
  }
  if (!Util.isUnset(request.openId)) {
    query['OpenId'] = request.openId;
  }
  if (!Util.isUnset(request.openIdAppKey)) {
    query['OpenIdAppKey'] = request.openIdAppKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetAccountById',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getAccountById(request: GetAccountByIdRequest): GetAccountByIdResponse {
  var runtime = new Util.RuntimeOptions{};
  return getAccountByIdWithOptions(request, runtime);
}

model GetDeviceStatusRequest {
  deviceName?: string(name='DeviceName', example='Device01'),
  iotId?: string(name='IotId', example='C47T6xwp6ms4bNlkHRWCg4****'),
  productKey?: string(name='ProductKey', example='a1Bw******'),
}

model GetDeviceStatusResponseBody = {
  code?: string(name='Code', example='400'),
  data?: {
    status?: string(name='Status', example='ONLINE'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage', example='Unexpected internal error.'),
  requestId?: string(name='RequestId', example='E55***B7-4***-4***-8***-D3******F565'),
  success?: boolean(name='Success', example='true'),
}

model GetDeviceStatusResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetDeviceStatusResponseBody(name='body'),
}

async function getDeviceStatusWithOptions(request: GetDeviceStatusRequest, runtime: Util.RuntimeOptions): GetDeviceStatusResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.deviceName)) {
    query['DeviceName'] = request.deviceName;
  }
  if (!Util.isUnset(request.iotId)) {
    query['IotId'] = request.iotId;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetDeviceStatus',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getDeviceStatus(request: GetDeviceStatusRequest): GetDeviceStatusResponse {
  var runtime = new Util.RuntimeOptions{};
  return getDeviceStatusWithOptions(request, runtime);
}

model GetSubDeviceListRequest {
  deviceName?: string(name='DeviceName', example='Device01'),
  iotId?: string(name='IotId', example='C47T6xwp6ms4bNlkHRWCg4****'),
  pageNo?: int32(name='PageNo', example='1'),
  pageSize?: int32(name='PageSize', example='5'),
  productKey?: string(name='ProductKey', example='a1Bw******'),
}

model GetSubDeviceListResponseBody = {
  code?: string(name='Code', example='400'),
  data?: {
    pageNo?: int32(name='PageNo', example='1'),
    pageSize?: int32(name='PageSize', example='1'),
    subDeviceList?: [ 
      {
        deviceName?: string(name='DeviceName', example='device-test'),
        iotId?: string(name='IotId', example='qswdfrttgg*********'),
        productKey?: string(name='ProductKey', example='wse5******'),
      }
    ](name='SubDeviceList'),
    total?: long(name='Total', example='1'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage', example='Request parameter error.'),
  requestId?: string(name='RequestId', example='E55***B7-4***-4***-8***-D3******F565'),
  success?: boolean(name='Success', example='true'),
}

model GetSubDeviceListResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetSubDeviceListResponseBody(name='body'),
}

async function getSubDeviceListWithOptions(request: GetSubDeviceListRequest, runtime: Util.RuntimeOptions): GetSubDeviceListResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.deviceName)) {
    query['DeviceName'] = request.deviceName;
  }
  if (!Util.isUnset(request.iotId)) {
    query['IotId'] = request.iotId;
  }
  if (!Util.isUnset(request.pageNo)) {
    query['PageNo'] = request.pageNo;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetSubDeviceList',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getSubDeviceList(request: GetSubDeviceListRequest): GetSubDeviceListResponse {
  var runtime = new Util.RuntimeOptions{};
  return getSubDeviceListWithOptions(request, runtime);
}

model GetThingEventSnapshotRequest {
  deviceName?: string(name='DeviceName', example='Device01'),
  identifier?: string(name='Identifier', example='AlarmType'),
  iotId?: string(name='IotId', example='C47T6xwp6ms4bNlkHRWCg4****'),
  productKey?: string(name='ProductKey', example='a1Bw******'),
}

model GetThingEventSnapshotResponseBody = {
  code?: string(name='Code', example='400'),
  data?: [ 
    {
      eventBody?: string(name='EventBody', example='{\\"EventList \\":[{\\"AlarmPicID \\":\\"\\",\\"EventTime \\":\\"1700010288542 \\",\\"AlarmType \\":1,\\"AlarmPicSize \\":1,\\"Data \\":\\"test \\"}]}'),
      eventCode?: string(name='EventCode', example='IntelligentAlarm'),
      eventType?: string(name='EventType', example='alert'),
      identifier?: string(name='Identifier', example='IntelligentAlarm'),
      iotId?: string(name='IotId', example='C47T6xwp6ms4bNlkHRWCg4****'),
      timestamp?: long(name='Timestamp', example='1700010288668'),
    }
  ](name='Data'),
  errorMessage?: string(name='ErrorMessage', example='Unexpected internal error.'),
  requestId?: string(name='RequestId', example='E55***B7-4***-4***-8***-D3******F565'),
  success?: boolean(name='Success', example='true'),
}

model GetThingEventSnapshotResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetThingEventSnapshotResponseBody(name='body'),
}

async function getThingEventSnapshotWithOptions(request: GetThingEventSnapshotRequest, runtime: Util.RuntimeOptions): GetThingEventSnapshotResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.deviceName)) {
    query['DeviceName'] = request.deviceName;
  }
  if (!Util.isUnset(request.identifier)) {
    query['Identifier'] = request.identifier;
  }
  if (!Util.isUnset(request.iotId)) {
    query['IotId'] = request.iotId;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetThingEventSnapshot',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getThingEventSnapshot(request: GetThingEventSnapshotRequest): GetThingEventSnapshotResponse {
  var runtime = new Util.RuntimeOptions{};
  return getThingEventSnapshotWithOptions(request, runtime);
}

model GetThingPropertySnapshotRequest {
  deviceName?: string(name='DeviceName', example='Device01'),
  iotId?: string(name='IotId', example='C47T6xwp6ms4bNlkHRWCg4****'),
  productKey?: string(name='ProductKey', example='a1Bw******'),
}

model GetThingPropertySnapshotResponseBody = {
  code?: string(name='Code', example='400'),
  data?: string(name='Data', example='{\\"StreamVideoQuality\\":{\\"time\\":1699951400324,\\"value\\":\\"0\\"},\\"MotionDetectSensitivity\\":{\\"time\\":1699951400324,\\"value\\":\\"0\\"},\\"ImageFlipState\\":{\\"time\\":1699951400324,\\"value\\":\\"0\\"},\\"SubStreamVideoQuality\\":{\\"time\\":1699951400324,\\"value\\":\\"0\\"},\\"AlarmSwitch\\":{\\"time\\":1699951400324,\\"value\\":\\"0\\"},\\"AlarmFrequencyLevel\\":{\\"time\\":1700009930921,\\"value\\":\\"10\\"}}'),
  errorMessage?: string(name='ErrorMessage', example='Request parameter error.'),
  requestId?: string(name='RequestId', example='E55***B7-4***-4***-8***-D3******F565'),
  success?: boolean(name='Success', example='true'),
}

model GetThingPropertySnapshotResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetThingPropertySnapshotResponseBody(name='body'),
}

async function getThingPropertySnapshotWithOptions(request: GetThingPropertySnapshotRequest, runtime: Util.RuntimeOptions): GetThingPropertySnapshotResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.deviceName)) {
    query['DeviceName'] = request.deviceName;
  }
  if (!Util.isUnset(request.iotId)) {
    query['IotId'] = request.iotId;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetThingPropertySnapshot',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getThingPropertySnapshot(request: GetThingPropertySnapshotRequest): GetThingPropertySnapshotResponse {
  var runtime = new Util.RuntimeOptions{};
  return getThingPropertySnapshotWithOptions(request, runtime);
}

model InvokeThingServiceRequest {
  args?: string(name='Args', example='{"param1":1}'),
  deviceName?: string(name='DeviceName', example='Device01'),
  identifier?: string(name='Identifier', example='SetNum'),
  iotId?: string(name='IotId', example='C47T6xwp6ms4bNlkHRWCg4****'),
  productKey?: string(name='ProductKey', example='a1Bw******'),
}

model InvokeThingServiceResponseBody = {
  code?: string(name='Code', example='400'),
  data?: {
    data?: string(name='Data', example='{"param1":1}'),
    messageId?: string(name='MessageId', example='abcabcabc1234****'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage', example='Request parameter error.'),
  requestId?: string(name='RequestId', example='E55***B7-4***-4***-8***-D3******F565'),
  success?: boolean(name='Success', example='true'),
}

model InvokeThingServiceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: InvokeThingServiceResponseBody(name='body'),
}

async function invokeThingServiceWithOptions(request: InvokeThingServiceRequest, runtime: Util.RuntimeOptions): InvokeThingServiceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.args)) {
    query['Args'] = request.args;
  }
  if (!Util.isUnset(request.deviceName)) {
    query['DeviceName'] = request.deviceName;
  }
  if (!Util.isUnset(request.identifier)) {
    query['Identifier'] = request.identifier;
  }
  if (!Util.isUnset(request.iotId)) {
    query['IotId'] = request.iotId;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'InvokeThingService',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function invokeThingService(request: InvokeThingServiceRequest): InvokeThingServiceResponse {
  var runtime = new Util.RuntimeOptions{};
  return invokeThingServiceWithOptions(request, runtime);
}

model ListBindingAccountByDeviceRequest {
  deviceName?: string(name='DeviceName', example='Device01'),
  iotId?: string(name='IotId', example='C47T6xwp6ms4bNlkHRWCg4****'),
  owned?: int32(name='Owned', example='0'),
  pageNo?: int32(name='PageNo', example='1'),
  pageSize?: int32(name='PageSize', example='5'),
  productKey?: string(name='ProductKey', example='a1Bw******'),
}

model ListBindingAccountByDeviceResponseBody = {
  code?: string(name='Code', example='400'),
  data?: {
    accountList?: [ 
      {
        bindTime?: long(name='BindTime', example='2222220000000'),
        identityAlias?: string(name='IdentityAlias', example='18*******20'),
        identityId?: string(name='IdentityId', example='5035op97******************a63994'),
      }
    ](name='AccountList'),
    pageNo?: int32(name='PageNo', example='1'),
    pageSize?: int32(name='PageSize', example='1'),
    total?: int32(name='Total', example='1'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage', example='Unexpected internal error.'),
  requestId?: string(name='RequestId', example='E55***B7-4***-4***-8***-D3******F565'),
  success?: boolean(name='Success', example='true'),
}

model ListBindingAccountByDeviceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListBindingAccountByDeviceResponseBody(name='body'),
}

async function listBindingAccountByDeviceWithOptions(request: ListBindingAccountByDeviceRequest, runtime: Util.RuntimeOptions): ListBindingAccountByDeviceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.deviceName)) {
    query['DeviceName'] = request.deviceName;
  }
  if (!Util.isUnset(request.iotId)) {
    query['IotId'] = request.iotId;
  }
  if (!Util.isUnset(request.owned)) {
    query['Owned'] = request.owned;
  }
  if (!Util.isUnset(request.pageNo)) {
    query['PageNo'] = request.pageNo;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListBindingAccountByDevice',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listBindingAccountByDevice(request: ListBindingAccountByDeviceRequest): ListBindingAccountByDeviceResponse {
  var runtime = new Util.RuntimeOptions{};
  return listBindingAccountByDeviceWithOptions(request, runtime);
}

model ListBindingDeviceByAccountRequest {
  identityId?: string(name='IdentityId'),
  openId?: string(name='OpenId'),
  openIdAppKey?: string(name='OpenIdAppKey'),
  pageNo?: int32(name='PageNo'),
  pageSize?: int32(name='PageSize'),
  subDevice?: boolean(name='SubDevice'),
}

model ListBindingDeviceByAccountResponseBody = {
  code?: string(name='Code'),
  data?: {
    deviceList?: [ 
      {
        bindTime?: long(name='BindTime'),
        deviceName?: string(name='DeviceName'),
        iotId?: string(name='IotId'),
        nodeType?: string(name='NodeType'),
        owned?: int32(name='Owned'),
        productKey?: string(name='ProductKey'),
      }
    ](name='DeviceList'),
    pageCount?: int32(name='PageCount'),
    pageNo?: int32(name='PageNo'),
    pageSize?: int32(name='PageSize'),
    total?: long(name='Total'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model ListBindingDeviceByAccountResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListBindingDeviceByAccountResponseBody(name='body'),
}

async function listBindingDeviceByAccountWithOptions(request: ListBindingDeviceByAccountRequest, runtime: Util.RuntimeOptions): ListBindingDeviceByAccountResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.identityId)) {
    query['IdentityId'] = request.identityId;
  }
  if (!Util.isUnset(request.openId)) {
    query['OpenId'] = request.openId;
  }
  if (!Util.isUnset(request.openIdAppKey)) {
    query['OpenIdAppKey'] = request.openIdAppKey;
  }
  if (!Util.isUnset(request.pageNo)) {
    query['PageNo'] = request.pageNo;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.subDevice)) {
    query['SubDevice'] = request.subDevice;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListBindingDeviceByAccount',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listBindingDeviceByAccount(request: ListBindingDeviceByAccountRequest): ListBindingDeviceByAccountResponse {
  var runtime = new Util.RuntimeOptions{};
  return listBindingDeviceByAccountWithOptions(request, runtime);
}

model QueryBatchStatusRequest {
  batchId?: string(name='BatchId'),
  productKey?: string(name='ProductKey'),
  projectId?: string(name='ProjectId'),
}

model QueryBatchStatusResponseBody = {
  code?: string(name='Code'),
  data?: {
    invalidDetailList?: [ 
      {
        deviceName?: string(name='DeviceName'),
        errorMsg?: string(name='ErrorMsg'),
      }
    ](name='InvalidDetailList'),
    invalidList?: [ string ](name='InvalidList'),
    status?: string(name='Status'),
    validList?: [ string ](name='ValidList'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model QueryBatchStatusResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryBatchStatusResponseBody(name='body'),
}

async function queryBatchStatusWithOptions(request: QueryBatchStatusRequest, runtime: Util.RuntimeOptions): QueryBatchStatusResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.batchId)) {
    query['BatchId'] = request.batchId;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  if (!Util.isUnset(request.projectId)) {
    query['ProjectId'] = request.projectId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'QueryBatchStatus',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryBatchStatus(request: QueryBatchStatusRequest): QueryBatchStatusResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryBatchStatusWithOptions(request, runtime);
}

model QueryDeviceDetailRequest {
  deviceName?: string(name='DeviceName', example='Device01'),
  iotId?: string(name='IotId', example='C47T6xwp6ms4bNlkHRWCg4****'),
  productKey?: string(name='ProductKey', example='a1Bw******'),
  projectId?: string(name='ProjectId', example='a123qs*****sy4QU'),
}

model QueryDeviceDetailResponseBody = {
  code?: string(name='Code', example='400'),
  data?: {
    activeTime?: long(name='ActiveTime', example='1934500000000'),
    createTime?: long(name='CreateTime', example='1834500000000'),
    deviceName?: string(name='DeviceName', example='Device01'),
    deviceSecret?: string(name='DeviceSecret', example='mz2Canp4GB7qRVf1OYPNtRqB2anu****'),
    firmwareVersion?: string(name='FirmwareVersion', example='V1.0.0.0'),
    iotId?: string(name='IotId', example='C47T6xwp6ms4bNlkHRWCg4****'),
    ipAddress?: string(name='IpAddress', example='10.***.***.***'),
    nickname?: string(name='Nickname', example='detectors_in_beijing'),
    nodeType?: int32(name='NodeType', example='0'),
    onlineTime?: long(name='OnlineTime', example='2298700000000'),
    productKey?: string(name='ProductKey', example='a1Bw******'),
    productName?: string(name='ProductName', example='test'),
    region?: string(name='Region', example='cn-shanghai'),
    status?: string(name='Status', example='ONLINE'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage', example='Request parameter error.'),
  requestId?: string(name='RequestId', example='E55***B7-4***-4***-8***-D3******F565'),
  success?: boolean(name='Success', example='true'),
}

model QueryDeviceDetailResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryDeviceDetailResponseBody(name='body'),
}

async function queryDeviceDetailWithOptions(request: QueryDeviceDetailRequest, runtime: Util.RuntimeOptions): QueryDeviceDetailResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.deviceName)) {
    query['DeviceName'] = request.deviceName;
  }
  if (!Util.isUnset(request.iotId)) {
    query['IotId'] = request.iotId;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  if (!Util.isUnset(request.projectId)) {
    query['ProjectId'] = request.projectId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'QueryDeviceDetail',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryDeviceDetail(request: QueryDeviceDetailRequest): QueryDeviceDetailResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryDeviceDetailWithOptions(request, runtime);
}

model QueryDevicesDownloadUrlRequest {
  batchId?: string(name='BatchId'),
  productKey?: string(name='ProductKey'),
}

model QueryDevicesDownloadUrlResponseBody = {
  code?: string(name='Code'),
  data?: {
    ossDownloadUrl?: string(name='OssDownloadUrl'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model QueryDevicesDownloadUrlResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryDevicesDownloadUrlResponseBody(name='body'),
}

async function queryDevicesDownloadUrlWithOptions(request: QueryDevicesDownloadUrlRequest, runtime: Util.RuntimeOptions): QueryDevicesDownloadUrlResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.batchId)) {
    query['BatchId'] = request.batchId;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'QueryDevicesDownloadUrl',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryDevicesDownloadUrl(request: QueryDevicesDownloadUrlRequest): QueryDevicesDownloadUrlResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryDevicesDownloadUrlWithOptions(request, runtime);
}

model QueryFreeStorageRequest {
  deviceName?: string(name='DeviceName'),
  iotId?: string(name='IotId'),
  productKey?: string(name='ProductKey'),
}

model QueryFreeStorageResponseBody = {
  code?: string(name='Code'),
  data?: {
    consumed?: int32(name='Consumed'),
    endTime?: string(name='EndTime'),
    endTimeUTC?: string(name='EndTimeUTC'),
    expired?: int32(name='Expired'),
    lifecycle?: int32(name='Lifecycle'),
    months?: int32(name='Months'),
    remainQuota?: int32(name='RemainQuota'),
    startTime?: string(name='StartTime'),
    startTimeUTC?: string(name='StartTimeUTC'),
    type?: int32(name='Type'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model QueryFreeStorageResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryFreeStorageResponseBody(name='body'),
}

async function queryFreeStorageWithOptions(request: QueryFreeStorageRequest, runtime: Util.RuntimeOptions): QueryFreeStorageResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.deviceName)) {
    query['DeviceName'] = request.deviceName;
  }
  if (!Util.isUnset(request.iotId)) {
    query['IotId'] = request.iotId;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'QueryFreeStorage',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryFreeStorage(request: QueryFreeStorageRequest): QueryFreeStorageResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryFreeStorageWithOptions(request, runtime);
}

model QueryGenerateDevicesInfoListRequest {
  batchId?: string(name='BatchId'),
  pageNo?: int32(name='PageNo'),
  pageSize?: int32(name='PageSize'),
  projectId?: string(name='ProjectId'),
}

model QueryGenerateDevicesInfoListResponseBody = {
  code?: string(name='Code'),
  data?: {
    listData?: [ 
      {
        deviceName?: string(name='DeviceName'),
        deviceSecret?: string(name='DeviceSecret'),
        iotId?: string(name='IotId'),
      }
    ](name='ListData'),
    pageNo?: int32(name='PageNo'),
    pageSize?: int32(name='PageSize'),
    total?: int32(name='Total'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model QueryGenerateDevicesInfoListResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryGenerateDevicesInfoListResponseBody(name='body'),
}

async function queryGenerateDevicesInfoListWithOptions(request: QueryGenerateDevicesInfoListRequest, runtime: Util.RuntimeOptions): QueryGenerateDevicesInfoListResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.batchId)) {
    query['BatchId'] = request.batchId;
  }
  if (!Util.isUnset(request.pageNo)) {
    query['PageNo'] = request.pageNo;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.projectId)) {
    query['ProjectId'] = request.projectId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'QueryGenerateDevicesInfoList',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryGenerateDevicesInfoList(request: QueryGenerateDevicesInfoListRequest): QueryGenerateDevicesInfoListResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryGenerateDevicesInfoListWithOptions(request, runtime);
}

model QueryGenerateDevicesRecordRequest {
  endTime?: long(name='EndTime', example='1659283200000'),
  pageNo?: int32(name='PageNo', example='1'),
  pageSize?: int32(name='PageSize', example='1'),
  startTime?: long(name='StartTime', example='1690819200000'),
}

model QueryGenerateDevicesRecordResponseBody = {
  code?: string(name='Code', example='400'),
  data?: {
    listData?: [ 
      {
        applyDeviceCount?: long(name='ApplyDeviceCount', example='133'),
        batchId?: string(name='BatchId', example='1508******195'),
        batchStatus?: string(name='BatchStatus', example='CREATE'),
        createTime?: long(name='CreateTime', example='1690819200000'),
        networkType?: string(name='NetworkType', example='WIFI'),
        operateUid?: long(name='OperateUid', example='110000000000'),
        productKey?: string(name='ProductKey', example='a3w******'),
        productName?: string(name='ProductName'),
        specCode?: string(name='SpecCode', example='Consumer_IPC_512Kbps'),
        successCount?: long(name='SuccessCount', example='5'),
      }
    ](name='ListData'),
    pageNo?: int32(name='PageNo', example='1'),
    pageSize?: int32(name='PageSize', example='1'),
    total?: int32(name='Total', example='5'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage', example='Request parameter error.'),
  requestId?: string(name='RequestId', example='E5******-4***-***B-8**E-D3********65'),
  success?: boolean(name='Success', example='true'),
}

model QueryGenerateDevicesRecordResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryGenerateDevicesRecordResponseBody(name='body'),
}

async function queryGenerateDevicesRecordWithOptions(request: QueryGenerateDevicesRecordRequest, runtime: Util.RuntimeOptions): QueryGenerateDevicesRecordResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.endTime)) {
    body['EndTime'] = request.endTime;
  }
  if (!Util.isUnset(request.pageNo)) {
    body['PageNo'] = request.pageNo;
  }
  if (!Util.isUnset(request.pageSize)) {
    body['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.startTime)) {
    body['StartTime'] = request.startTime;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'QueryGenerateDevicesRecord',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryGenerateDevicesRecord(request: QueryGenerateDevicesRecordRequest): QueryGenerateDevicesRecordResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryGenerateDevicesRecordWithOptions(request, runtime);
}

model QueryStorageCommodityListResponseBody = {
  code?: string(name='Code'),
  data?: [ 
    {
      commodityCode?: string(name='CommodityCode'),
      commodityName?: string(name='CommodityName'),
      lifecycle?: int32(name='Lifecycle'),
      months?: int32(name='Months'),
      price?: string(name='Price'),
      recordType?: int32(name='RecordType'),
      specification?: string(name='Specification'),
    }
  ](name='Data'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model QueryStorageCommodityListResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryStorageCommodityListResponseBody(name='body'),
}

async function queryStorageCommodityListWithOptions(runtime: Util.RuntimeOptions): QueryStorageCommodityListResponse {
  var req = new OpenApi.OpenApiRequest{};
  var params = new OpenApi.Params{
    action = 'QueryStorageCommodityList',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryStorageCommodityList(): QueryStorageCommodityListResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryStorageCommodityListWithOptions(runtime);
}

model QueryStorageOrderRequest {
  deviceName?: string(name='DeviceName'),
  deviceNoOwner?: boolean(name='DeviceNoOwner'),
  iotId?: string(name='IotId'),
  orderId?: string(name='OrderId'),
  productKey?: string(name='ProductKey'),
}

model QueryStorageOrderResponseBody = {
  code?: string(name='Code'),
  data?: {
    commodityCode?: string(name='CommodityCode'),
    copies?: int32(name='Copies'),
    endTime?: string(name='EndTime'),
    endTimeUTC?: string(name='EndTimeUTC'),
    identityId?: string(name='IdentityId'),
    iotId?: string(name='IotId'),
    orderId?: string(name='OrderId'),
    orderType?: int32(name='OrderType'),
    outOrderNo?: string(name='OutOrderNo'),
    paymentStatus?: int32(name='PaymentStatus'),
    preConsume?: int32(name='PreConsume'),
    price?: string(name='Price'),
    recordType?: int32(name='RecordType'),
    specification?: string(name='Specification'),
    startTime?: string(name='StartTime'),
    startTimeUTC?: string(name='StartTimeUTC'),
    status?: int32(name='Status'),
    userId?: string(name='UserId'),
    userName?: string(name='UserName'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model QueryStorageOrderResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryStorageOrderResponseBody(name='body'),
}

async function queryStorageOrderWithOptions(request: QueryStorageOrderRequest, runtime: Util.RuntimeOptions): QueryStorageOrderResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.deviceName)) {
    query['DeviceName'] = request.deviceName;
  }
  if (!Util.isUnset(request.deviceNoOwner)) {
    query['DeviceNoOwner'] = request.deviceNoOwner;
  }
  if (!Util.isUnset(request.iotId)) {
    query['IotId'] = request.iotId;
  }
  if (!Util.isUnset(request.orderId)) {
    query['OrderId'] = request.orderId;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'QueryStorageOrder',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryStorageOrder(request: QueryStorageOrderRequest): QueryStorageOrderResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryStorageOrderWithOptions(request, runtime);
}

model QueryStorageOrderListRequest {
  deviceName?: string(name='DeviceName'),
  deviceNoOwner?: boolean(name='DeviceNoOwner'),
  iotId?: string(name='IotId'),
  pageNo?: int32(name='PageNo'),
  pageSize?: int32(name='PageSize'),
  productKey?: string(name='ProductKey'),
}

model QueryStorageOrderListResponseBody = {
  code?: string(name='Code'),
  data?: {
    pageCount?: int32(name='PageCount'),
    pageNo?: int32(name='PageNo'),
    pageSize?: int32(name='PageSize'),
    storageOrderList?: [ 
      {
        commodityCode?: string(name='CommodityCode'),
        copies?: int32(name='Copies'),
        endTime?: string(name='EndTime'),
        endTimeUTC?: string(name='EndTimeUTC'),
        identityId?: string(name='IdentityId'),
        iotId?: string(name='IotId'),
        orderId?: string(name='OrderId'),
        orderType?: int32(name='OrderType'),
        outOrderNo?: string(name='OutOrderNo'),
        paymentStatus?: int32(name='PaymentStatus'),
        preConsume?: int32(name='PreConsume'),
        price?: string(name='Price'),
        recordType?: int32(name='RecordType'),
        specification?: string(name='Specification'),
        startTime?: string(name='StartTime'),
        startTimeUTC?: string(name='StartTimeUTC'),
        status?: int32(name='Status'),
        userId?: string(name='UserId'),
        userName?: string(name='UserName'),
      }
    ](name='StorageOrderList'),
    total?: int32(name='Total'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model QueryStorageOrderListResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryStorageOrderListResponseBody(name='body'),
}

async function queryStorageOrderListWithOptions(request: QueryStorageOrderListRequest, runtime: Util.RuntimeOptions): QueryStorageOrderListResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.deviceName)) {
    query['DeviceName'] = request.deviceName;
  }
  if (!Util.isUnset(request.deviceNoOwner)) {
    query['DeviceNoOwner'] = request.deviceNoOwner;
  }
  if (!Util.isUnset(request.iotId)) {
    query['IotId'] = request.iotId;
  }
  if (!Util.isUnset(request.pageNo)) {
    query['PageNo'] = request.pageNo;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'QueryStorageOrderList',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryStorageOrderList(request: QueryStorageOrderListRequest): QueryStorageOrderListResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryStorageOrderListWithOptions(request, runtime);
}

model SetThingPropertyRequest {
  args?: string(name='Args', example='{"Switch":1,"Color":"blue"}'),
  deviceName?: string(name='DeviceName', example='Device01'),
  iotId?: string(name='IotId', example='C47T6xwp6ms4bNlkHRWCg4****'),
  productKey?: string(name='ProductKey', example='a1Bw******'),
}

model SetThingPropertyResponseBody = {
  code?: string(name='Code', example='400'),
  errorMessage?: string(name='ErrorMessage', example='Request parameter error.'),
  requestId?: string(name='RequestId', example='E55***B7-4***-4***-8***-D3******F565'),
  success?: boolean(name='Success', example='true'),
}

model SetThingPropertyResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: SetThingPropertyResponseBody(name='body'),
}

async function setThingPropertyWithOptions(request: SetThingPropertyRequest, runtime: Util.RuntimeOptions): SetThingPropertyResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.args)) {
    query['Args'] = request.args;
  }
  if (!Util.isUnset(request.deviceName)) {
    query['DeviceName'] = request.deviceName;
  }
  if (!Util.isUnset(request.iotId)) {
    query['IotId'] = request.iotId;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SetThingProperty',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function setThingProperty(request: SetThingPropertyRequest): SetThingPropertyResponse {
  var runtime = new Util.RuntimeOptions{};
  return setThingPropertyWithOptions(request, runtime);
}

model TransferStorageOrderRequest {
  dstIotId?: string(name='DstIotId'),
  enableDefaultPlan?: boolean(name='EnableDefaultPlan'),
  eventRecordDuration?: int32(name='EventRecordDuration'),
  eventRecordProlong?: boolean(name='EventRecordProlong'),
  immediateUse?: boolean(name='ImmediateUse'),
  preRecordDuration?: int32(name='PreRecordDuration'),
  srcIotId?: string(name='SrcIotId'),
  srcOrderId?: string(name='SrcOrderId'),
  supportCrossIdentityTransfer?: boolean(name='SupportCrossIdentityTransfer'),
  userId?: string(name='UserId'),
  userName?: string(name='UserName'),
}

model TransferStorageOrderResponseBody = {
  code?: string(name='Code'),
  data?: {
    commodityCode?: string(name='CommodityCode'),
    copies?: int32(name='Copies'),
    endTime?: string(name='EndTime'),
    endTimeUTC?: string(name='EndTimeUTC'),
    identityId?: string(name='IdentityId'),
    iotId?: string(name='IotId'),
    orderId?: string(name='OrderId'),
    orderType?: int32(name='OrderType'),
    outOrderNo?: string(name='OutOrderNo'),
    paymentStatus?: int32(name='PaymentStatus'),
    preConsume?: int32(name='PreConsume'),
    price?: string(name='Price'),
    recordType?: int32(name='RecordType'),
    specification?: string(name='Specification'),
    startTime?: string(name='StartTime'),
    startTimeUTC?: string(name='StartTimeUTC'),
    status?: int32(name='Status'),
    userId?: string(name='UserId'),
    userName?: string(name='UserName'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model TransferStorageOrderResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: TransferStorageOrderResponseBody(name='body'),
}

async function transferStorageOrderWithOptions(request: TransferStorageOrderRequest, runtime: Util.RuntimeOptions): TransferStorageOrderResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.dstIotId)) {
    query['DstIotId'] = request.dstIotId;
  }
  if (!Util.isUnset(request.enableDefaultPlan)) {
    query['EnableDefaultPlan'] = request.enableDefaultPlan;
  }
  if (!Util.isUnset(request.eventRecordDuration)) {
    query['EventRecordDuration'] = request.eventRecordDuration;
  }
  if (!Util.isUnset(request.eventRecordProlong)) {
    query['EventRecordProlong'] = request.eventRecordProlong;
  }
  if (!Util.isUnset(request.immediateUse)) {
    query['ImmediateUse'] = request.immediateUse;
  }
  if (!Util.isUnset(request.preRecordDuration)) {
    query['PreRecordDuration'] = request.preRecordDuration;
  }
  if (!Util.isUnset(request.srcIotId)) {
    query['SrcIotId'] = request.srcIotId;
  }
  if (!Util.isUnset(request.srcOrderId)) {
    query['SrcOrderId'] = request.srcOrderId;
  }
  if (!Util.isUnset(request.supportCrossIdentityTransfer)) {
    query['SupportCrossIdentityTransfer'] = request.supportCrossIdentityTransfer;
  }
  if (!Util.isUnset(request.userId)) {
    query['UserId'] = request.userId;
  }
  if (!Util.isUnset(request.userName)) {
    query['UserName'] = request.userName;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'TransferStorageOrder',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function transferStorageOrder(request: TransferStorageOrderRequest): TransferStorageOrderResponse {
  var runtime = new Util.RuntimeOptions{};
  return transferStorageOrderWithOptions(request, runtime);
}

model UnbindAllUserByDeviceRequest {
  deviceName?: string(name='DeviceName'),
  iotId?: string(name='IotId'),
  productKey?: string(name='ProductKey'),
  unbindSubDevice?: boolean(name='UnbindSubDevice'),
}

model UnbindAllUserByDeviceResponseBody = {
  code?: string(name='Code'),
  data?: {
    subDeviceUnbindResult?: [ 
      {
        deviceName?: string(name='DeviceName'),
        iotId?: string(name='IotId'),
        productKey?: string(name='ProductKey'),
        unbindResultCode?: int32(name='UnbindResultCode'),
        unbindResultMessage?: string(name='UnbindResultMessage'),
      }
    ](name='SubDeviceUnbindResult'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model UnbindAllUserByDeviceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: UnbindAllUserByDeviceResponseBody(name='body'),
}

async function unbindAllUserByDeviceWithOptions(request: UnbindAllUserByDeviceRequest, runtime: Util.RuntimeOptions): UnbindAllUserByDeviceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.deviceName)) {
    query['DeviceName'] = request.deviceName;
  }
  if (!Util.isUnset(request.iotId)) {
    query['IotId'] = request.iotId;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  if (!Util.isUnset(request.unbindSubDevice)) {
    query['UnbindSubDevice'] = request.unbindSubDevice;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'UnbindAllUserByDevice',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function unbindAllUserByDevice(request: UnbindAllUserByDeviceRequest): UnbindAllUserByDeviceResponse {
  var runtime = new Util.RuntimeOptions{};
  return unbindAllUserByDeviceWithOptions(request, runtime);
}

model UnbindDeviceRequest {
  deviceName?: string(name='DeviceName'),
  identityId?: string(name='IdentityId'),
  iotId?: string(name='IotId'),
  openId?: string(name='OpenId'),
  openIdAppKey?: string(name='OpenIdAppKey'),
  productKey?: string(name='ProductKey'),
  unbindSubDevice?: boolean(name='UnbindSubDevice'),
}

model UnbindDeviceResponseBody = {
  code?: string(name='Code'),
  data?: {
    subDeviceUnbindResult?: [ 
      {
        deviceName?: string(name='DeviceName'),
        iotId?: string(name='IotId'),
        productKey?: string(name='ProductKey'),
        unbindResultCode?: int32(name='UnbindResultCode'),
        unbindResultMessage?: string(name='UnbindResultMessage'),
      }
    ](name='SubDeviceUnbindResult'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model UnbindDeviceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: UnbindDeviceResponseBody(name='body'),
}

async function unbindDeviceWithOptions(request: UnbindDeviceRequest, runtime: Util.RuntimeOptions): UnbindDeviceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.deviceName)) {
    query['DeviceName'] = request.deviceName;
  }
  if (!Util.isUnset(request.identityId)) {
    query['IdentityId'] = request.identityId;
  }
  if (!Util.isUnset(request.iotId)) {
    query['IotId'] = request.iotId;
  }
  if (!Util.isUnset(request.openId)) {
    query['OpenId'] = request.openId;
  }
  if (!Util.isUnset(request.openIdAppKey)) {
    query['OpenIdAppKey'] = request.openIdAppKey;
  }
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  if (!Util.isUnset(request.unbindSubDevice)) {
    query['UnbindSubDevice'] = request.unbindSubDevice;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'UnbindDevice',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function unbindDevice(request: UnbindDeviceRequest): UnbindDeviceResponse {
  var runtime = new Util.RuntimeOptions{};
  return unbindDeviceWithOptions(request, runtime);
}

model UploadDeviceNameListRequest {
  deviceNames?: [ string ](name='DeviceNames'),
  productKey?: string(name='ProductKey'),
  projectId?: string(name='ProjectId'),
}

model UploadDeviceNameListResponseBody = {
  code?: string(name='Code'),
  data?: {
    batchId?: string(name='BatchId'),
    invalidDetailList?: [ 
      {
        deviceName?: string(name='DeviceName'),
        errorMsg?: string(name='ErrorMsg'),
      }
    ](name='InvalidDetailList'),
    invalidDeviceNameList?: [ string ](name='InvalidDeviceNameList'),
    repeatedDeviceNameList?: [ string ](name='RepeatedDeviceNameList'),
  }(name='Data'),
  errorMessage?: string(name='ErrorMessage'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model UploadDeviceNameListResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: UploadDeviceNameListResponseBody(name='body'),
}

async function uploadDeviceNameListWithOptions(request: UploadDeviceNameListRequest, runtime: Util.RuntimeOptions): UploadDeviceNameListResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.productKey)) {
    query['ProductKey'] = request.productKey;
  }
  if (!Util.isUnset(request.projectId)) {
    query['ProjectId'] = request.projectId;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.deviceNames)) {
    body['DeviceNames'] = request.deviceNames;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'UploadDeviceNameList',
    version = '2023-06-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function uploadDeviceNameList(request: UploadDeviceNameListRequest): UploadDeviceNameListResponse {
  var runtime = new Util.RuntimeOptions{};
  return uploadDeviceNameListWithOptions(request, runtime);
}

